package com.nut.sp.controller;

import com.nut.sp.model.User;
import com.nut.sp.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
public class SampleController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private UserService userService;


    @RequestMapping("/listUser")
    @ResponseBody
    public List<User> listUser() {
        Long a = 1L;
        logger.info("yuge test!{} : {} ", a, 222);
        return userService.findAll();
    }


    @RequestMapping("/roll")
    @ResponseBody
    public String roll() {
        User u = new User();
        u.setCreateTime(new Date());
        u.setRealName("bbb");
        userService.insert(u);
        return "s";
    }
}
